toast('开始');
 
//复制别人的问题，提出问题
/*

while(!click("最新")){
    ui.run(function(){
        w.text.setText('最新');
    });
    sleep(2000);
}

var wenti=className("android.view.View").depth(11).drawingOrder(0).indexInParent(3).find()
//log(wenti)
i=0
while(wenti[i].text()){
        
    //toast(wenti[i].text())    //geyi
    //sleep(1000)

if(wenti[i].text().indexOf("？") >-1|| wenti[i].text().indexOf("？")>-1){

    //if(wenti[i])//名字
    toastLog(wenti[i].text());
    sleep(1000)


发布话题=className("android.view.View").depth(4).drawingOrder(0).indexInParent(3).text("发布话题")
发布话题.find()

click(1000,1900)
className("EditText").findOne().setText(wenti[i].text());
sleep(5000)


//发布话题.click()
//click("发布话题")
click("立即发布")
sleep(5000)
}
i=i+1;
    if(i>2)break
}*/


/* while(1){
    
 

        答案=className("android.view.View").depth(9).drawingOrder(0).indexInParent(3).findOnce().text()
        toastLog(答案);

        click(500,2180)
        sleep(1000)

        className("EditText").findOne().setText(答案);
        sleep(5000)
        click("发布回答")
        sleep(5000)

        back()
        sleep(1000)
        
} */
while (1) {
    sleep(3000)
    while(!click("最新")){
        ui.run(function(){
            w.text.setText('最新');
        });
        sleep(2000);
    }
    click(800, 1150)
    sleep(5000)

   if (className("android.view.View").textContains("问答详情")) {
  /*        if (className("android.view.View").depth(7).drawingOrder(0).indexInParent(11).exists()) {
            toastLog("88");
            back()
            sleep(1000)
        }
        else { */
            var mingzi = className("android.view.View").depth(9).drawingOrder(0).indexInParent(1).find()
            if (mingzi[0].text() == "改成你的名字") {
                toastLog("886");
                back()
                sleep(1000)
            }

            else {

            答案 = className("android.view.View").depth(9).drawingOrder(0).indexInParent(3).findOnce().text()
            toastLog(答案);

            click(500, 2180)
            sleep(1000)

            className("EditText").findOne().setText(答案);
            sleep(5000)
            click("发布回答")
            sleep(5000)

            back()
            sleep(1000)
            }
        }
  /*   }
    else {
        toastLog("wrong");

    } */
    swipe(500, 1545, 500, 1137, 500)
    toast('下滑');
    sleep(1000)

}

//点开别人的问题，复制别人的回答，回答
/*页面内部 不动
下滑对控件读取没有帮助
该点不到就是点不到
*/
j = 0
while (j < 5) {

    var huida = className("android.view.View").depth(11).drawingOrder(0).indexInParent(4).find()
    log(huida)
    i = 0
    while (huida[i].text()) {

        if (huida[i].text().indexOf("1回答") > -1 || huida[i].text().indexOf("2回答") > -1 || huida[i].text().indexOf("3回答") > -1) {
            toast(huida[i].text())

            while (className("android.view.View").depth(5).textContains("问答详情")) {

                scrollDown()
                classNameEndsWith("WebView").scrollable().findOne().scrollDown();
                toast('下滑');
                sleep(3000)
                a = className("android.view.View").depth(11).drawingOrder(0).indexInParent(4).find()
                sleep(2000)
                k = 0
                /* while(k<5){
                        toast(a[k].text())
                    sleep(2000)
                    if(a[k].text().indexOf("1回答") >-1|| a[k].text().indexOf("2回答")>-1|| a[k].text().indexOf("3回答")>-1){
                            click(a[k].text())
                        sleep(2000)
                        if(className("android.view.View").textContains("问答详情")) break;
    
                        k=k+1
                    }
                } */
                if (className("android.view.View").textContains("问答详情")) break;


            }



            答案 = className("android.view.View").depth(9).drawingOrder(0).indexInParent(3).findOnce().text()
            toastLog(答案);

            click(500, 2180)
            sleep(1000)

            className("EditText").findOne().setText(答案);
            sleep(5000)
            click("发布回答")
            sleep(5000)

            back()
            sleep(1000)
        }
        toast(i)
        i = i + 1;
        if (i > 15) break
    }
    click('热门')
    click(80, 500)
    sleep(2000)
    click('最新')
    click(250, 500)
    sleep(2000)

    toast(j)
    j = j + 1
}
toast('结束');